<?php

class Slides extends MY_Controller {
	public function __construct(){
		parent::__construct();
	}

	public function index(){
		$this->load->model('galleries_Model', 'gallery', true);
		$result = $this->gallery->find_all();
		return $this->load->view('slides/slide', array('slide' => $result, 'path' => $this->get_assets()), true);
	}

	public function admin(){
		$this->load->language('slide', $this->config->item('language'));
		$this->load->library('grocery_crud');
		$crud = new grocery_CRUD();
		$crud->set_table("galleries");
		$crud->columns("title","image","caption","link");
		$crud->display_as("id","id")
			->display_as("title", lang('slide.title'))
			->display_as("image", lang('slide.image')." (750 x 470)")
			->display_as("caption", lang('slide.caption'))
			->display_as("link", lang('slide.link'))
			->display_as("status", lang('slide.status'))
			->display_as("order", lang('slide.order'));
		$crud->edit_fields("title","image","caption","link");
		$crud->add_fields("title","image","caption","link");

		$crud -> set_field_upload('image', 'uploads/slides');

		$crud->set_subject(lang('slide.subject'));

		//validate
		$crud -> set_rules('title', lang('slide.title'), 'required');
		$crud -> set_rules('image', lang('slide.image'), 'required');
		$crud -> set_rules('caption', lang('slide.caption'), 'required');
		$crud -> set_rules('link', lang('slide.link'), 'required');

		//$output = $crud->render();
		return $crud->render();
	}
}
?>